package com.air.config;

public class Result<T> {
    private Integer code;
    private String msg;
    private Boolean success;
    private T data;

    public Result() {
    }

    public Result(Integer code, String msg, Boolean success, T data) {
        this.code = code;
        this.msg = msg;
        this.success = success;
        this.data = data;
    }

    public static <E> Result<E> success(String msg, E data) {
        return new Result<>(200, msg, true, data);
    }

    public static <E> Result<E> fail(String msg) {
        return new Result<>(500, msg, false, null);
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Boolean getSuccess() {
        return success;
    }

    public void setSuccess(Boolean success) {
        this.success = success;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
